
<template>
  <basic-container class="plan-container">
    <el-container style="height: 100%;">
      <el-aside v-if="isOpen" width="220px" style="background-color: #ffffff; border-right:1px solid #e3e3e3;">
        <el-breadcrumb class="projectNameCrumb" style="width:235px">
            <el-breadcrumb-item class="projectNameCrumbItem"  style="width:235px">
              <span>项目：</span>
              {{projectInfo.projectName}}
            </el-breadcrumb-item>
        </el-breadcrumb>
        <div style="padding:10px 5px;">
          <avue-tree :option="treeOption"  :data="treeData" :loading="showLoading"  @update="updataIteration" @save="saveNewIteration" @del="deleteIteration" v-model="iterationForm" @node-click="iterationNodeClick">
            <span class="el-tree-node__label" slot-scope="{ node, data }">
              <span> 
                <i v-if="node.level == 2" class="el-icon-notebook-2" style="float:left;padding: 3px 3px 0 0; "></i>
                <span :style="data.id == currentIteration.id? 'font-weight:bold; color:#409eff; float:left': 'float:left'">{{data.iterationName }}</span>
              </span>
            </span>
          </avue-tree>
        </div>
      </el-aside> 
      <el-container>
        <el-header style="height:40px;font-size: 12px">
          <div style="padding-top:5px;float:left; width:100%;">
            <div style="float:left;">
              <el-button style="color:#666;font-size:16px; padding-top:5px; font-weight:bold;" :icon="isOpen? 'el-icon-s-fold' : 'el-icon-s-unfold'" type="text"  @click="isOpen = !isOpen">{{currentIteration.iterationName}}</el-button>
            </div>
            <div class="kanban-select" style="float:right;">
                <el-button v-if="showType != 1" style="color:#666;font-size:16px; padding-top:5px; padding-left:10px; font-weight:normal;" type="text" icon='el-icon-s-operation'  @click="changeViewMode(1)">看板</el-button>
                <el-button v-if="showType != 2" style="color:#666;font-size:16px; padding-top:5px; padding-left:10px; font-weight:normal;" type="text" icon='el-icon-menu'  @click="changeViewMode(2)">列表</el-button>
                <el-button style="color:#666;font-size:16px; padding-top:5px; padding-left:10px; font-weight:normal;" type="text" icon='el-icon-s-data'  @click="openGantt">甘特图</el-button>              
            </div>
          </div>
        </el-header>
    
        <el-main v-if="showType == 1"> 
          <div v-if="showType == 1" class="kanban-select" style="float:left;width:70%">
              <avue-form v-model="searchForm" :option="searchOption" @submit="searchKanbanPlan"></avue-form>
          </div>
          <div  class="components-container board" style="float:left; margin-top:20px;">
            <Kanban v-for="(item, index) in milestoneData" :style="'width:'+item.widthValue +'px; margin:10px;margin-bottom:30px;'" 
              :key="index" 
              :group="group" 
              class="kanban todo" 
              :milestoneData="item" 
              @openAddPlanDialog='openAddPlanDialog'
              @openUpdatePlanDialog='openUpdatePlanDialog'
              @handlePlanDrag='handlePlanDrag'
              @deletePlan='deletePlan'
            />
            <!-- <Kanban style="width:300px; margin:10px;" :key="2" :list="list2" :group="group" class="kanban working" header-text="Working" />
            <Kanban style="width:300px; margin:10px;" :key="3" :list="list3" :group="group" class="kanban done" header-text="Done" /> -->
          <div class="add-more" @click='handleOpenMilestone'>
              <i class="el-icon-plus" style="font-weight: bold;"></i>新增里程碑
          </div>
          </div> 
        </el-main> 
        <el-main  v-if="showType == 2"> 
          <div style="padding-top:0px;">
            <avue-crud :option="planOption"
                      :table-loading="loading"
                      :data="planTreeData"
                      ref="planCrud"
                      v-model="planForm"
                      :defaults.sync="showColumn"
                      :permission="permissionList"
                      :page.sync="page"
                      :before-open="beforePlanOpen"
                      @row-del="rowDel"
                      @row-update="rowUpdate"
                      @row-save="submitPlanForm"
                      @refresh-change="refreshChange"
                      @search-change="searchChange"
                      @search-reset="searchReset"
                      @selection-change="selectionChange"
                      @current-change="currentChange"
                      @size-change="sizeChange"
                      @filter-change="filterChange"
                      @row-dblclick="handleRowDBLClick"               
                      @on-load="onLoad">
              <template slot-scope="scope" slot="planName">
                <span :style="(!scope.row.children || scope.row.children.length == 0) && scope.row.parentPlanId == '' ? '': ''">
                </span>
              </template>
              <template slot-scope="scope" slot="menuForm">
                <div  style="text-align:right; float:right">
                  <el-button type="text"  v-if="operateType == 'edit'"   icon="el-icon-time" style="font-weight:normal;" size="large" @click.stop="getHistoryRecord">修改历史</el-button>
                </div> 
              </template>
              <template slot-scope="scope" slot="menuLeft">
                <el-button type="primary"
                          size="small"
                          icon="el-icon-plus"
                          v-if="permission.biz_plan_manage_batch_add"
                          @click.stop="openBatchAddDialog">批量新增
                </el-button>
                <el-button type="primary"
                          size="small"
                          icon="el-icon-s-data"
                          @click.stop="openGantt">甘特图
                </el-button>
                <el-button type="danger"
                          size="small"
                          icon="el-icon-delete"
                          v-if="permission.biz_plan_manage_batch_delete"
                          @click.stop="handleDelete">删 除
                </el-button>
              </template>
              <template slot="menuRight">
                <el-button v-if="permission.biz_plan_manage_download" type="default" @click.stop="exportExcel"  title="下载" icon="el-icon-download" circle size="small"></el-button>
              </template>
            </avue-crud>
          </div>
        </el-main> 
        
      </el-container>
    </el-container>
    <!-- 新增里程碑 -->
    <el-dialog title="里程碑管理" width="70%" :visible.sync="milestoneDialog" :destroy-on-close='true'  :close-on-click-modal="false">
      <avue-crud  :option="milestoneOption" 
                    :data="milestoneData"
                    :table-loading="loading"
                    ref="milestoneCrud"
                    v-model="milestoneForm"
                    :permission="permissionList"
                    :page.sync="milestonePage"
                    :before-open="beforeOpen"
                    @row-update="milestoneAddUpdate"
                    @row-del="milestoneRowDel"
                    @refresh-change="milestoneRefreshChange"
                    @sortable-change="milestoneSaveOrUpdate"
                    @row-click="selectCurrentRow"
                    @selection-change="milestoneSelectionChange"
                    >
          <template slot="menuLeft">
            <!-- <el-button @click="milestoneAddRow" 
                      icon="el-icon-circle-plus-outline" 
                      type="primary" 
                      size="small">新增字段
            </el-button> -->
            
            <!-- <el-button type="primary"
                      size="small"
                      icon="el-icon-save"
                      v-if="permission.database_delete"
                      @click="milestoneSaveOrUpdate">全部保存
            </el-button> -->
          </template>
        </avue-crud>
    </el-dialog>
    <!-- 新增计划 -->
    <el-dialog title="新增需求计划" width="70%" :visible.sync="planDialog" :destroy-on-close='true' :close-on-click-modal="false">
       <avue-form 
          ref="planFormDialog" 
          v-model="planForm" 
          :option="addPlanOption"  
          @submit="submitPlanForm"
        >
        <template slot-scope="scope" slot="conferenceAttList">
          <file-selector
                :fileList="form.conferenceAttList"
                openType="edit"
                :multiple="true"
                @changeFileList='changeFileList'
              >
          </file-selector>
        </template>
        <template  slot-scope="scope" slot="menuForm">
            <el-button type="danger" icon="el-icon-close" @click="planDialog = false">关闭</el-button>
        </template>
      </avue-form> 
    </el-dialog>
    <!-- 修改计划 -->
    <el-dialog title="修改需求计划" width="70%" :visible.sync="updatePlanDialog" :destroy-on-close='true' :close-on-click-modal="false">
       <avue-form 
          ref="updatePlanFormDialog" 
          v-model="planForm" 
          :option="updatePlanOption"  
          @submit="updatePlan"
        >
        <template slot-scope="scope" slot="conferenceAttList">
          <file-selector
                :fileList="form.conferenceAttList"
                openType="edit"
                :multiple="true"
                @changeFileList='changeFileList'
              >
          </file-selector>
        </template>
        <template  slot-scope="scope" slot="menuForm">
            <el-button type="danger" icon="el-icon-close" @click="updatePlanDialog = false">关闭</el-button>
            <div  style="text-align:right; float:right">
              <el-button type="text"  icon="el-icon-time" style="font-weight:normal;" size="large" @click.stop="getHistoryRecord">修改历史</el-button>
            </div> 
        </template>
      </avue-form> 
    </el-dialog>
    <!-- 计划甘特图 -->
    <el-dialog title="计划甘特图" width="100%" top="0vh" :visible.sync="ganttDialog" :append-to-body='true' :close-on-click-modal="false">
      <gantt 
              ref="gantt"
              :milestoneData="milestoneData"
              :planTreeData="planTreeData" 
              @openAddPlanDialog='openAddPlanDialog'
              @openUpdatePlanDialog='openUpdatePlanDialog'
              @handlePlanDrag='handlePlanDrag'
              @deletePlan='deletePlan'
              @handleTaskDate='handleTaskDate'
              @loadMilestone='loadMilestone'
              @loadPlanList='loadPlanList'
      >
      </gantt> 
    </el-dialog>
    <!-- 历史记录 -->
    <update-history ref="historyRecord"></update-history>
  </basic-container>
</template>

<script>
import {exportBizPlanMilestoneExcel,saveOrUpdateBizPlanMilestone,saveOrUpdateBizPlanMilestoneList,saveBizPlanMilestone,saveBizPlanMilestoneList,deleteBizPlanMilestone,queryBizPlanMilestone,queryBizPlanMilestoneListPage,updateBizPlanMilestone,deleteBizPlanMilestoneList} from '@/api/biz/plan/bizPlanMilestoneApi';
import {exportBizPlanIterationExcel,saveOrUpdateBizPlanIteration,saveOrUpdateBizPlanIterationList,saveBizPlanIteration,saveBizPlanIterationList,deleteBizPlanIteration,queryBizPlanIteration,queryBizPlanIterationListPage,updateBizPlanIteration,deleteBizPlanIterationList} from '@/api/biz/plan/bizPlanIterationApi';
import {exportBizPlanManageExcel,saveOrUpdateBizPlanManage,saveOrUpdateBizPlanManageList,saveBizPlanManage,saveBizPlanManageList,deleteBizPlanManage,queryBizPlanManage,queryBizPlanManageListPage,updateBizPlanManage,deleteBizPlanManageList} from '@/api/biz/plan/bizPlanManageApi';
import {mapGetters} from 'vuex';
import { reqCommonMsg } from '@/util/reqCommonMsg';
import {filterFormat} from '@/util/util';
import Kanban from '../../components/kanban'
import Gantt from '../../components/gantt'
export default {
  components: {
    Kanban,
    Gantt
  },
  data() {
    return {
      
      //甘特图
      ganttDialog: false,
      // 循环调用检查
      isFound: false,
      // 看板搜索框
      searchForm:{},
      searchOption:{
        labelSuffix: '：',
        menuSpan:3,
        emptyBtn: false,
        submitText:'搜索',
        submitIcon:'el-icon-search',
        column: [
          {
            label: '计划名称',
            prop: 'planName',
            placeholder:'计划名称',
            span:11,
            rules: [{
              required: false,
              message: '请输入计划名称',
              trigger: 'blur'
            }]
          },
          {
            label: '责任人姓名',
            prop: 'respsbltPersonUserName', 
            type: 'select', 
            placeholder:'责任人姓名',
            span: 9,
            rules: [],
            dicData:[],
            remote: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            props: {
              label: 'realName',
              value: 'realName'
            },
          },  
        ]
      },
      // 当前打开form对话框操作类型 
      operateType: 'add',
      //显示列表还是看板
      showPlanKanban: true,
      showType: 1,
      //判读是否有拖动变化
      isDragChange: false,
      //里程碑
      milestoneDialog:false,
      headerText:{
        title: '待处理',
        planDuring: '2021/01/01 - 2021/03/03'
      },
      //左侧展现控制
      isOpen: true,

      // 组织目录树形区
      showLoading: true,
      hasFoundParent: false,
      checkedNode: '',
      iterationForm:{},
      currentIteration: {
        id:'DOOL1001ITER99999999',
        iterationName:'所有迭代',
      },
      treeData:[{
        id:'DOOL1001ITER99999999',
        iterationName:'所有迭代',
        children:[]
      }],
      lastParentId: '',
      lastParentIterationName: '', //iterationName
      treeOption:{
        title:'新增根目录',
        addBtn: true,
        menu: true,
        defaultExpandAll:true,
        formOption:{
          labelWidth:100,
          column:[{
            label: '迭代名称',
            prop: 'iterationName', 
            type: 'input', 
            span: 12,
            maxlength: 50,
            rules: [{
              message: '请输入迭代名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '迭代描述',
            prop: 'iterationDesc', 
            type: 'input', 
            span: 12,
            maxlength: 2000,
            rules: [{
              message: '请输入迭代描述',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 2000,
              message: '内容长度不能超过2000字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '版本类型',
            prop: 'versionType', 
            type: 'select', 
            span: 12,
            maxlength: 30,
            rules: [{
              message: '请输入版本类型',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '版本窗口',
            prop: 'versionWindowDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            span: 12,
            maxlength: 20,
            rules: [{
              message: '请输入版本窗口日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '开始日期',
            prop: 'iterationBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            span: 12,
            maxlength: 20,
            rules: [{
              message: '请输入迭代开始日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '结束日期',
            prop: 'iterationEndDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            span: 12,
            maxlength: 20,
            rules: [{
              message: '请输入迭代结束日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          }],
        },
        props:{
          label:'iterationName',
          value:'id'
        }
      },
      //里程碑数据 
      milestoneData: [],
      milestoneType: [],
      currentMilestone:{},
      milestoneForm: {},
      milestoneOption: {
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 125,
        dialogTop: '50',
        indexFixed:true, 
        stripe:true,
        calcHeight: 80,
        searchShow: true,
        searchMenuSpan: 6,
        tip: false,
        border: true,
        index: true,
        selection: true,
        addBtn: true,
        viewBtn: false,
        delBtn: true,
        cancelBtn: true,
        printBtn:false,
        saveBtn: true,
        filterBtn:true,          
        menuWidth: 150,
        dialogMenuPosition: 'center',
        dialogDirection:'rtl',
        dialogType:'dialog',
        dialogFullscreen:false,
        dialogClickModal:false,
        dialogWidth: '70%',
        highlightCurrentRow:  true,
        sortable: false,
        submitText: '保存',
        emptyBtn:false,
        column: [
          {
            label: '里程碑名称',
            prop: 'milestoneName', 
            type: 'input', 
            maxlength: 50,
            width: 200,
            rules: [{
              message: '请输入里程碑名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '里程碑说明',
            prop: 'milestoneDesc', 
            type: 'input', 
            maxlength: 2000,
            width: 200,
            rules: [{
              message: '请输入里程碑描述',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 2000,
              message: '内容长度不能超过2000字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '计划开始日期',
            prop: 'planBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            width: 150,
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            maxlength: 20,
            rules: [{
              message: '请输入计划开始日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              this.milestoneForm.planBeginDate = value;
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.milestoneForm.planBeginDate;
                  let endDate = this.milestoneForm.planEndDate; 
                  if(beginDate > endDate){
                    this.milestoneForm.planBeginDate = endDate;
                  }
                  this.milestoneForm.investmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },

          {
            label: '计划结束日期',
            prop: 'planEndDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            width: 150,
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            maxlength: 20,
            rules: [{
              message: '请输入计划结束日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              this.milestoneForm.planEndDate   = value;
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.milestoneForm.planBeginDate;
                  let endDate = this.milestoneForm.planEndDate; 
                  if(beginDate > endDate){
                    this.milestoneForm.planEndDate   = beginDate;
                  }
                  this.milestoneForm.investmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '投入用时(天)',
            prop: 'investmentTime', 
            type: 'input',  
            maxlength: 20, 
            value: '300',
            width: 120,
            rules: [{
              message: '请输入宽度',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '显示宽度',
            prop: 'widthValue', 
            type: 'number',  
            maxlength: 20, 
            value: '300',
            maxRows: 600,
            minRows: 200,
            width: 120,
            span: 6,
            rules: [{
              message: '请输入宽度',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '便签头高度',
            prop: 'heightValue', 
            type: 'number',  
            maxlength: 20, 
            value: '55',
            maxRows: 100,
            minRows: 20,
            width: 120,
            span: 6,
            rules: [{
              message: '请输入高度',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '允许添加计划',
            prop: 'addPlanFlag', 
            type: 'switch', 
            span: 6,
            value: '1',
            width: 120,
            rules: [],
            dicData:[
              {
                label: '否',
                value: '0'
              },
              {
                label: '是',
                value: '1'
              }
            ],
          },
          {
            label: '允许拖动',
            prop: 'dragFlag', 
            type: 'switch', 
            span: 6,
            value: '1',
            width: 120,
            rules: [],
            dicData:[
              {
                label: '否',
                value: '0'
              },
              {
                label: '是',
                value: '1'
              }
            ],
          },
          {
            label: '便签颜色',
            prop: 'color', 
            type: 'color',  
            maxlength: 50, 
            value: '#3089dc',
            width: 180,
            span: 12,
            rules: [{
              message: '请输入颜色',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '甘特图标识名',
            prop: 'flagName', 
            type: 'input',  
            maxlength: 50, 
            value: '',
            width: 200,
            span: 12,
            rules: [{
              message: '标志名称',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '标识样式',
            prop: 'flagStyleName', 
            type: 'select',  
            maxlength: 50, 
            value: '',
            span: 12,
            rules: [{
              message: '标志名称',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[{
              label: '红色',
              value: 'red_line'
            },{
              label: '浅蓝色',
              value: 'blue_line'
            },{
              label: '深蓝色',
              value: 'dark_blue_line'
            },{
              label: '粉色',
              value: 'pink_line'
            },{
              label: '黑色',
              value: 'black_line'
            },{
              label: '浅绿',
              value: 'green_line'
            },{
              label: '深绿',
              value: 'dark_green_line'
            },{
              label: '橙色',
              value: 'orange_line'
            },{
              label: '黄色',
              value: 'yellow_line'
            },{
              label: '紫色',
              value: 'purple_line'
            }],
          },
        ]
      },

      //计划数据
      planUserList:[],
      showColumn: {},
      currentPlan:{},
      planForm: {},
      planData: [],
      planTreeData: [],
      selectionList: [],
      planOption:{
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 125,
        dialogTop: '50',
        indexFixed:true, 
        stripe:true,
        calcHeight: 80,
        searchShow: true,
        searchMenuSpan: 6,
        tip: false,
        border: true,
        index: true,
        selection: true,
        addBtn: true,
        viewBtn: false,
        delBtn: true,
        cancelBtn: true,
        printBtn:false,
        saveBtn: true,
        filterBtn:true,          
        menuWidth: 150,
        dialogMenuPosition: 'center',
        dialogDirection:'rtl',
        dialogType:'dialog',
        dialogFullscreen:false,
        dialogClickModal:false,
        dialogWidth: '70%',
        highlightCurrentRow:  true,
        sortable: false,
        submitText: '保存',
        emptyBtn:false,
        column: [  
          {
            label: '计划名称',
            prop: 'planName', 
            type: 'input', 
            span: 24,
            search: true,
            sortable: false,
            hide: false,
            width: 250,
            maxlength: 50,
            overHidden: true,
            slot: true,
            rules: [{
              message: '请输入计划名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '迭代名称',
            prop: 'iterationName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 24,
            sortable: false,
            hide: true,
            maxlength: 50,
            overHidden: true,
            addDisplay:false,
            editDisabled:true,
            rules: [{
              message: '请输入迭代名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '里程碑',
            prop: 'milestoneId', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            addDisplay:true,
            props:{
              label: 'milestoneName',
              value:'id'
            },
            rules: [{
              message: '请输入里程碑',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '计划类型',
            prop: 'planType', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span:12,
            sortable: false,
            hide: false,
            maxlength: 30,
            overHidden: true,
            value: '需求',
            rules: [{
              message: '请输入计划类型',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[
              {
                label: '需求',
                value: '需求'
              },
              {
                label: '任务',
                value: '任务'
              },
              {
                label: '其它',
                value: '其它'
              }
            ],
          },
          
          {
            label: '父级计划',
            prop: 'parentPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 50,
            
            overHidden: true,
            editDisabled:true,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入父级计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '前置计划',
            prop: 'prevPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            maxlength: 50,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入前置计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '责任人姓名',
            prop: 'respsbltPersonName', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入责任人',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
            remote: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            props: {
              label: 'realName',
              value: 'realName'
            },
          },
          {
            label: '干系人列表',
            prop: 'stakeholderList', 
            type: 'select', 
            multiple: true,
            filterable: true,
            remote: true,
            span:12,
            props: {
              label: 'realName',
              value: 'realName',
            },
            dicFlag: false,
            hide: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&remote=yes&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            rules: [{
              type: 'array',
              required: false,
              message: '请选择干系人',
            }],
            dicData:[],
          },
          {
            label: '计划开始日期',
            prop: 'planBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划开始日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planBeginDate = endDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划完成日期',
            prop: 'planFinishDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划完成日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planFinishDate = beginDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划投入用时',
            prop: 'planInvestmentTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 1,
            tip: '单位：天',
            rules: [{
              message: '请输入计划投入用时',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '剩余用时',
            prop: 'leftTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 1,
            tip: '单位：天',
            addDisplay:false,
            rules: [{
              message: '请输入剩余用时',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          
          {
            label: '实际开始日期',
            prop: 'actualBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 20,
            overHidden: true,
            addDisplay:false,
            rules: [{
              message: '请输入实际开始日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '实际完成日期',
            prop: 'actualFinishDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 20,
            overHidden: true,
            addDisplay:false,
            rules: [{
              message: '请输入实际完成日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '实际投入用时',
            prop: 'actualInvestmentTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: true,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 0,
            tip: '单位：天',
            addDisplay:false,
            rules: [{
              message: '请输入实际投入用时',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '进度(%)',
            prop: 'progress', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: false,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 0,
            addDisplay:false,
            tip: '百分比',
            rules: [{
              message: '请输入进度',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '优先级',
            prop: 'priorLevel', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 5,
            sortable: false,
            hide: true,
            maxlength: 30,
            overHidden: true,
            value: '中',
            rules: [{
              message: '请输入优先级',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '颜色',
            prop: 'color', 
            type: 'color', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 7,
            sortable: false,
            hide: true,
            maxlength: 50,
            overHidden: true,
            value: '#444444',
            rules: [{
              message: '请输入颜色',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[
            ],
          },
          
          {
            label: '计划描述',
            prop: 'planDesc', 
            type: 'textarea', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 24,
            sortable: false,
            hide: true,
            maxlength: 2000,
            overHidden: true,
            maxRows:3,
            minRows:3,
            rules: [{
              message: '请输入计划描述',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 2000,
              message: '内容长度不能超过2000字符',
              trigger: 'blur'
            }],
            dicData:[],
          }, 
          
        ]
      },

      //新增计划表单option
      planDialog: false,
      addPlanOption:{
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 125,
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 140,
        submitText: '保存',
        emptyBtn:false,
        column: [  
          {
            label: '计划名称',
            prop: 'planName', 
            type: 'input', 
            span: 24,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入计划名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '计划类型',
            prop: 'planType', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 30,
            overHidden: true,
            value: '需求',
            rules: [{
              message: '请输入计划类型',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[
              {
                label: '需求',
                value: '需求'
              },
              {
                label: '任务',
                value: '任务'
              },
              {
                label: '其它',
                value: '其它'
              }
            ],
          },
          {
            label: '里程碑',
            prop: 'milestoneId', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            disabled: false,
            props:{
              label: 'milestoneName',
              value:'id'
            },
            rules: [{
              message: '请输入里程碑',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '父级计划',
            prop: 'parentPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            maxlength: 50,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入父级计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '前置计划',
            prop: 'prevPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            maxlength: 50,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入前置计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '责任人姓名',
            prop: 'respsbltPersonName', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入责任人',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
            remote: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            props: {
              label: 'realName',
              value: 'realName'
            },
          },
          {
            label: '干系人列表',
            prop: 'stakeholderList', 
            type: 'select', 
            multiple: true,
            filterable: true,
            remote: true,
            span:12,
            props: {
              label: 'realName',
              value: 'realName',
            },
            dicFlag: false,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&remote=yes&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            rules: [{
              type: 'array',
              required: false,
              message: '请选择干系人',
            }],
            dicData:[],
          },
          {
            label: '计划开始日期',
            prop: 'planBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划开始日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planBeginDate = beginDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划完成日期',
            prop: 'planFinishDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划完成日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planFinishDate = beginDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划投入用时',
            prop: 'planInvestmentTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 1,
            tip: '单位：天',
            rules: [{
              message: '请输入计划投入用时',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          
          {
            label: '优先级',
            prop: 'priorLevel', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 5,
            sortable: false,
            hide: true,
            maxlength: 30,
            overHidden: true,
            value: '中',
            rules: [{
              message: '请输入优先级',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '颜色',
            prop: 'color', 
            type: 'color', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 7,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            value: '#444444',
            rules: [{
              message: '请输入颜色',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[
            ],
          },
          
          {
            label: '计划描述',
            prop: 'planDesc', 
            type: 'textarea', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 24,
            sortable: false,
            hide: false,
            maxlength: 2000,
            overHidden: true,
            maxRows:3,
            minRows:3,
            rules: [{
              message: '请输入计划描述',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 2000,
              message: '内容长度不能超过2000字符',
              trigger: 'blur'
            }],
            dicData:[],
          }, 
        ]
      },

      //修改计划表单option
      updatePlanDialog: false,
      updatePlanOption:{
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 125,
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 140,
        submitText: '保存',
        emptyBtn:false,
        column: [  
          {
            label: '计划名称',
            prop: 'planName', 
            type: 'input', 
            span: 24,
            search: true,
            sortable: false,
            hide: false,
            width: 250,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入计划名称',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '计划类型',
            prop: 'planType', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 30,
            overHidden: true,
            disabled: true,
            value: '需求',
            rules: [{
              message: '请输入计划类型',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[
              {
                label: '需求',
                value: '需求'
              },
              {
                label: '任务',
                value: '任务'
              },
              {
                label: '其它',
                value: '其它'
              }
            ],
          },
          {
            label: '里程碑',
            prop: 'milestoneId', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            addDisplay:true,
            props:{
              label: 'milestoneName',
              value:'id'
            },
            rules: [{
              message: '请输入里程碑',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          
          
          {
            label: '父级计划',
            prop: 'parentPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 50,
            disabled: true,
            overHidden: true,
            editDisabled:true,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入父级计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '前置计划',
            prop: 'prevPlanId', 
            type: 'tree', 
            dicFlag: true,
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            filterable: true,
            span: 12,
            maxlength: 50,
            props:{
              label: 'planName',
              value: 'id',
            },
            rules: [{
              message: '请输入前置计划',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '责任人姓名',
            prop: 'respsbltPersonName', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入责任人',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
            remote: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            props: {
              label: 'realName',
              value: 'realName'
            },
          },
          {
            label: '干系人列表',
            prop: 'stakeholderList', 
            type: 'select', 
            multiple: true,
            filterable: true,
            remote: true,
            span:12,
            props: {
              label: 'realName',
              value: 'realName',
            },
            dicFlag: false,
            hide: true,
            dicMethod:'get',
            dicUrl: '/platform/sysUserInfo/querySysUserInfoListPage?optFlag=noorg&remote=yes&columnValue={{key}}&columnName=realName&tenantId='+localStorage.getItem('tenantId'),
            rules: [{
              type: 'array',
              required: false,
              message: '请选择干系人',
            }],
            dicData:[],
          },
          {
            label: '计划开始日期',
            prop: 'planBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划开始日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planBeginDate = beginDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划完成日期',
            prop: 'planFinishDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              // disabledDate(time) {
              //   return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              // }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 20,
            overHidden: true,
            rules: [{
              message: '请输入计划完成日期',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
            change: ({value,column}) => {
              if(value != ''){
                setTimeout(() => {
                  let beginDate = this.planForm.planBeginDate;
                  let endDate = this.planForm.planFinishDate; 
                  if(beginDate > endDate){
                    this.planForm.planFinishDate = beginDate;
                  }
                  this.planForm.planInvestmentTime = parseInt(this.$toolUtil.getWorkday(beginDate,endDate)); 
                }, 500);
              }
            }
          },
          {
            label: '计划投入用时',
            prop: 'planInvestmentTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 1,
            tip: '单位：天',
            rules: [{
              message: '请输入计划投入用时',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '剩余用时',
            prop: 'leftTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 1,
            tip: '单位：天',
            addDisplay:false,
            rules: [{
              message: '请输入剩余用时',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          
          {
            label: '实际开始日期',
            prop: 'actualBeginDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 20,
            overHidden: true,
            addDisplay:false,
            rules: [{
              message: '请输入实际开始日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '实际完成日期',
            prop: 'actualFinishDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            value: this.$toolUtil.formatDate(new Date()),
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: true,
            maxlength: 20,
            overHidden: true,
            addDisplay:false,
            rules: [{
              message: '请输入实际完成日期',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '实际投入用时',
            prop: 'actualInvestmentTime', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: true,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 0,
            tip: '单位：天',
            addDisplay:false,
            rules: [{
              message: '请输入实际投入用时',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '进度(%)',
            prop: 'progress', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: false,
            maxlength: 100,
            overHidden: true,
            precision: 1,
            maxRows:1000,
            minRows:1,
            value: 0,
            addDisplay:false,
            tip: '百分比',
            rules: [{
              message: '请输入进度',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '优先级',
            prop: 'priorLevel', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: true,
            maxlength: 30,
            overHidden: true,
            value: '中',
            rules: [{
              message: '请输入优先级',
              required:  true,
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '颜色',
            prop: 'color', 
            type: 'color', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 6,
            sortable: false,
            hide: true,
            maxlength: 50,
            overHidden: true,
            value: '#444444',
            rules: [{
              message: '请输入颜色',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[
            ],
          },
          
          {
            label: '计划描述',
            prop: 'planDesc', 
            type: 'textarea', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 24,
            sortable: false,
            hide: true,
            maxlength: 2000,
            overHidden: true,
            maxRows:3,
            minRows:3,
            rules: [{
              message: '请输入计划描述',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 2000,
              message: '内容长度不能超过2000字符',
              trigger: 'blur'
            }],
            dicData:[],
          }, 
          
        ]
      },

      loading: false,
      data:[],
      
      group: 'plan',
      
      // 请求参数区
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      reqParams: {
        singleBody: {},
        listBody: [{}],
        sqlCondition:[],
        orderRule: [],
        currentPage: 1,
        pageSize: 10
      },
      commonData: null,
      conditions: [],
      orderRules: [],
      singleBody: {}
    };
  },
  computed: {
    ...mapGetters(['website','orgTree','genOrgTree','userInfo','permission','projectInfo']),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.biz_plan_manage_add, false),
        viewBtn: this.vaildData(this.permission.biz_plan_manage_view, false),
        delBtn: this.vaildData(this.permission.biz_plan_manage_delete, false),
        editBtn: this.vaildData(this.permission.biz_plan_manage_edit, false),
        printBtn: this.vaildData(this.permission.biz_plan_manage_print, false),
        searchBtn:this.vaildData(this.permission.biz_plan_manage_search, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push({id : ele.id});
      });
      return ids;
    } 
  },
  methods: {
    /**
     * 列表，只展示最近20个迭代
     */
    async loadIteration() {
      this.showLoading =true;
      this.singleBody.projectNo = this.projectInfo.projectNo;
      this.reqParams =  {
        singleBody: this.singleBody,
        orderRule: {
          order: 'descending',
          prop: 'createDatetime'
        },
        currentPage:1, 
        pageSize: 20
      }
      
      this.commonData = reqCommonMsg(this.reqParams)
      await queryBizPlanIterationListPage(this.commonData).then(res => {
        this.treeData[0].children = [];
        res.data.body.listBody.forEach((element,index) => {
          //默认加载第一条为当前迭代
          if(this.treeData.length == 1 && index == 0){
            this.currentIteration = element;
          }
          this.treeData[0].children.push({
            ...element
          })
        });
        this.singleBody={};
        this.showLoading =false;
      }, error => {
        this.showLoading =false;
      });
    },
    
    /**
     * 添加新的迭代
     */
    saveNewIteration(parent,data,done,loading){
      //写记录
      this.reqParams.singleBody = {
        ...data,
        projectNo: this.projectInfo.projectNo,
        projectName: this.projectInfo.projectName
      };
      this.commonData = reqCommonMsg(this.reqParams)
      saveBizPlanIteration(this.commonData).then(() => {
        this.singleBody={};
        this.loadIteration();
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '操作成功!'
        });
        done(); 
      }, error => {
        loading();
        done();
      });         
    },
    updataIteration(data, parent, done,loading){
      this.reqParams.singleBody = parent;
      this.commonData = reqCommonMsg(this.reqParams)
      updateBizPlanIteration(this.commonData).then(() => {
        this.singleBody={};
        this.loadIteration();
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '修改成功!'
        });
        done();
      }, error => {
        loading();
        done();
      });
    },
    /*********************
     * 处理里程碑
     */
    /**
     * 目录树形菜单点击时触发事件
     */
    async iterationNodeClick(data){
      this.currentIteration =  data;
      await this.loadMilestone();
      await this.loadPlanList();
    },

    /**
     * 加载里程碑数据
     */
    async loadMilestone() {
      this.singleBody.projectNo = this.projectInfo.projectNo;
      this.singleBody.iterationNo = this.currentIteration.id;
      this.loading = true;
      this.reqParams =  {
        singleBody: this.singleBody,
        orderRule: {
          order: 'ascending',
          prop: 'orderSeq'
        },
        currentPage: 1, 
        pageSize: 99
      }
      this.commonData = reqCommonMsg(this.reqParams)
      await queryBizPlanMilestoneListPage(this.commonData).then(res => {
        this.milestoneData = res.data.body.listBody;
        this.milestoneType = [];
        this.milestoneData.forEach(element => {
          this.milestoneType.push({
            id: element.id,
            milestoneName: element.milestoneName
          })
          element.planList = [];
        });
        this.findObject(this.planOption.column, 'milestoneId').dicData = this.milestoneType;
        this.findObject(this.addPlanOption.column, 'milestoneId').dicData = this.milestoneType;
        this.findObject(this.updatePlanOption.column, 'milestoneId').dicData = this.milestoneType;
        this.loading = false; 
        if(this.planData){
          this.handleMilestonePlan();
        }
      }, error => {
        this.loading = false; 
      });
    },

    // 打开里程碑定义对话框
    handleOpenMilestone(){
      this.milestoneDialog = true; 
    },
    /**
     * 刷新里程碑
     */
    milestoneRefreshChange(){ 
      this.loadMilestone();
    },
    /**
     * 添加一行
     */
    milestoneAddRow(row) {
      // this.$message.success('添加成功！')
      this.$refs.milestoneCrud.rowCellAdd({
        id: '',
        projectNo: this.projectInfo.projectNo,
        projectName: this.projectInfo.projectName,
        iterationNo: this.currentIteration.id,
        iterationName: this.currentIteration.iterationName,
        milestoneName: '',
        milestoneDesc: '',
        orderSeq: this.milestoneData.length,
        planBeginDate: this.$toolUtil.formatDate(new Date()),
        planEndDate: this.$toolUtil.formatDate(new Date())
      });
    },
    
    milestoneAddUpdate(form,index,done,loading){
      this.loading = true;
      this.reqParams.singleBody = form;
      if(!this.reqParams.singleBody.id)
      {
        this.reqParams.singleBody.id='0'
      }
      this.commonData = reqCommonMsg(this.reqParams)
      saveOrUpdateBizPlanMilestone(this.commonData).then(() => {
        this.loadMilestone();
        this.handleMilestonePlan();
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '保存成功!'
        });
        this.loading = false;
        done();
      }, error => {
        this.loading = false;
        done();
      });
      //this.$console.log('loading = ',loading)
    },
    
    milestoneRowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.singleBody = row;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteBizPlanMilestone(this.commonData);
        })
        .then(() => {
          this.loadMilestone();
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
        }).catch(() => {});
    },
    milestoneSaveOrUpdate(){
      this.loading = true;
      // 整理顺序
      this.milestoneData.forEach((item, index) => {
        this.milestoneData[index].orderSeq = index;
      }); 
      this.reqParams.listBody = this.milestoneData;
      this.commonData = reqCommonMsg(this.reqParams)
      saveOrUpdateBizPlanMilestoneList(this.commonData).then(() => {
        this.loadMilestone();
        this.handleMilestonePlan();
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '保存成功!'
        });
        this.loading = false;
      }, error => {
        this.loading = false;
        //this.$console.log(error);
      });
      //this.$console.log('this.columnData = ',JSON.stringify(this.columnData))
    },
    /**
     * 批量编辑字段
     */
    milestoneBatchEdit(){
      this.columnData.forEach((item, index) => {
        this.columnData[index].$cellEdit = true; 
      }); 
    },
    /**
     * 字段选择
     */
    milestoneSelectionChange(list) {
      this.columnSelectionList = list;
    },
    milestoneSelectionClear() {
      this.columnSelectionList = [];
      this.$refs.columnCrud.toggleSelection();
    },
    /******************************
     * 处理计划列表
     */
    /**
     * 搜索重置
     */
    searchReset() {
      this.conditions =[];
      this.singleBody = {};
      this.loadPlanList();
    },

    /**
     * 看板搜索
     */
    searchKanbanPlan(row,done){
      this.$console.log('this.searchForm==',this.searchForm)
      let searchParam = {
        ...this.searchForm,
        respsbltPersonUserName: this.$util.formatUserName(this.searchForm.respsbltPersonUserName).userId// 使用用户名
      }
      this.loadPlanList(searchParam);
      done();
    },
    /**
     * 搜索
     */
    searchChange(params, done) {
      this.page.currentPage = 1;
      if(params.respsbltPersonName){
        params.respsbltPersonName = this.$util.formatUserName(params.respsbltPersonName).userName
      }
      this.loadPlanList(params);
      done();
    },
    refreshChange(){
      this.loadPlanList();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.planCrud.toggleSelection();
    },
    /**
     * 处理批量删除
     */
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.listBody = this.ids;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteBizPlanManageList(this.commonData);
        })
        .then(() => {
          this.loadPlanList(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.$refs.crud.toggleSelection();
        }).catch(() => {});
    },
    /**
     * 打开编辑、查询弹窗前查询记录
     */  
    beforePlanOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        this.operateType = 'edit';
        this.reqParams =  {
          singleBody: {
            id:this.planForm.id
          }
        }
        let commonData = reqCommonMsg(this.reqParams)
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading'
        });
        queryBizPlanManage(commonData).then(res => {
          this.planForm = res.data.body.singleBody;
          this.planForm.stakeholderList = JSON.parse(this.planForm.stakeholderList);
          this.planForm.respsbltPersonName = this.planForm.respsbltPersonName+'('+ this.planForm.respsbltPersonUserName+')';
          loading.close();
          done();
        }, error => {
          this.$console.log(error);
          loading.close();
          done();
        });
      }
      if (['add'].includes(type)) {
        this.operateType = 'add';
        done();
      }
    },
    /**
     * 切换视图
     */
    changeViewMode(showType){
      this.showType = showType;
      this.loadPlanList();
    },
    /**
     * 打开甘特图
     */
    openGantt(){
      this.ganttDialog = true;
      setTimeout(() => {
        this.$refs.gantt.handleTaskData(2);
      }, 100);
    },
    /**
     * 加载计划
     */
    async loadPlanList(item){
      let userSelect=[];
      this.loading = true;
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading'
      });
      this.singleBody = {
        ...item,
        projectNo: this.projectInfo.projectNo,
        iterationNo: this.currentIteration.id == 'DOOL1001ITER99999999'? '' : this.currentIteration.id
      }
      this.reqParams =  {
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: {
          order: 'ascending',
          prop: 'orderSeq'
        },
        currentPage: 1, 
        pageSize: 99999
      }
      this.commonData = reqCommonMsg(this.reqParams)
      await queryBizPlanManageListPage(this.commonData).then(res => {
        this.planData = res.data.body.listBody;
        this.planData.forEach(element => {
          element.stakeholderList = JSON.parse(element.stakeholderList);
          
        });
        loading.close();
        this.loading = false;
      }, error => {
        this.loading = false; 
        loading.close();
      });
      // 按照里程碑阶段处理计划列表
      // 先按照所有的按照里程碑名字整理，后期看效果。
      this.handleMilestonePlan(item);
      this.handleMilestonePlanByTree(item);
    },
    /**
     * 按照里程碑阶段处理计划列表
     * 先按照所有的按照里程碑名字整理，后期看效果。
     */
    handleMilestonePlan(item){
      let getCurrentMilestone = false;
      this.milestoneData.forEach(element => {
        element.planList = [];
        element.planCount = 0;
        this.planData.forEach(planElement => {
          if(element.milestoneName == planElement.milestoneName){
            element.planList.push(
              planElement
            )
            element.planCount++;
          }
          //获取第一个能添加计划的里程碑 为当前里程碑
          if(element.addPlanFlag=='1' && !getCurrentMilestone){
            getCurrentMilestone = true;
            this.currentMilestone = element;
          }
        });
        element.milestoneType = this.milestoneType;
        element.dragPermission = this.permission.biz_plan_manage_drag
      });      
    },
    /**
     * 处理计划树形结构
     */
    handleMilestonePlanByTree(item){
      this.planTreeData = [];
      let planChildList=[];
      //搜索时展示搜索结果，不展示树形
      if(item && JSON.stringify(item) != '{}'){
        this.planTreeData = this.planData;
      }
      else{
        this.planData.forEach(planElement => {
          if(planElement.parentPlanId !=''){
            planChildList.push(
              planElement
            )
          }
        });   
        //处理树形
        this.planData.forEach(planElement => {
          planElement.children = [];
          planChildList.forEach(childElement => {
            if(planElement.id == childElement.parentPlanId){
              planElement.children.push(childElement)
            }
          })
          if(planElement.parentPlanId ==''){
            this.planTreeData.push(
              planElement
            )
          }
        });  
        this.findObject(this.planOption.column, 'parentPlanId').dicData = this.planTreeData;
        this.findObject(this.addPlanOption.column, 'parentPlanId').dicData = this.planTreeData;
        this.findObject(this.updatePlanOption.column, 'parentPlanId').dicData = this.planTreeData;
        this.findObject(this.planOption.column, 'prevPlanId').dicData = this.planTreeData;
        this.findObject(this.addPlanOption.column, 'prevPlanId').dicData = this.planTreeData;
        this.findObject(this.updatePlanOption.column, 'prevPlanId').dicData = this.planTreeData;

      }
    },
    /**
     * 打开添加计划窗口，组件调用
     */
    openAddPlanDialog(row){
      this.planDialog = true;
      if(row){
        this.currentMilestone =  row;
        this.planForm.milestoneId = row.id;
      }
    },
    /**
     * 新增一条计划
     */
    submitPlanForm(row,done) {
      console.log('===this.planForm===',this.planForm)
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading'
      });
      this.reqParams.singleBody = {
        ...this.planForm,
        projectNo: this.projectInfo.projectNo,
        projectName: this.projectInfo.projectName,
        iterationNo: this.currentIteration.id,
        iterationName: this.currentIteration.iterationName,
        milestoneId: this.planForm.milestoneId || this.currentMilestone.id,
        milestoneName: this.planForm.$milestoneId ||this.currentMilestone.milestoneName,
        parentPlanName: this.planForm.$parentPlanId,
        prevPlanName: this.planForm.$prevPlanId,
        respsbltPersonName:this.$util.formatUserName(this.planForm.respsbltPersonName).userName,// 使用人名
        respsbltPersonUserName:this.$util.formatUserName(this.planForm.respsbltPersonName).userId// 使用用户名
      }
      this.commonData = reqCommonMsg(this.reqParams)
      saveBizPlanManage(this.commonData).then(() => {
        this.singleBody={};
        this.loadPlanList();
        this.$message({
          type: 'success',
          message: '添加成功!'
        });
        done();
        this.planDialog = false;
        loading.close();
      }, error => {
        done();
        loading.close();
      });         
    },
    /**
     * 拖动变化时批量处理数据
     */
    handlePlanDrag(){
      if(this.isDragChange){
        this.isDragChange =  false;
        this.$console.log('handlePlanDrag==',this.milestoneData);
        //遍历所有里程碑
        let allPlanDate=[];
        this.milestoneData.forEach(element => {
          element.planList.forEach((planElement,idx) => {
            planElement.milestoneId = element.id;
            planElement.milestoneName = element.milestoneName;
            planElement.orderSeq = idx;
            allPlanDate.push(
              planElement
            )
          });
        });
        
        //批量保存
        this.reqParams.listBody = allPlanDate;
        this.commonData = reqCommonMsg(this.reqParams)
        saveOrUpdateBizPlanManageList(this.commonData).then(() => {
          this.handleMilestonePlan();
          this.$console.log('==保存成功！');
        }, error => {
          //this.$console.log(error);
        });
        this.$console.log('allPlanDate==',allPlanDate);
      }
    },

    /**
     * 打开添加计划窗口，组件调用
     */
    openUpdatePlanDialog(row){
      this.updatePlanDialog = true;
      this.planForm =  row;
      this.beforePlanOpen(()=>{}, 'edit')
    },
    /**
     * 递归查找是否有死循环调用
     */
    foundByIteration(id,orgId,parentPlanId){
      for(let i=0; i<this.planData.length; i++){
        if(this.planData[i].id == parentPlanId && this.planData[i].parentPlanId != ''){
          if(this.planData[i].parentPlanId == orgId ){
            this.$console.log('发现循环调用！');
            i=this.planData.length;
            this.isFound = true;
            return true;
          }
          else{
            this.foundByIteration(this.planData[i].id,orgId,this.planData[i].parentPlanId);
          }
        }
      }
      return false;
    },
    /**
     * 修改计划
     */
    updatePlan(row,done) {
      //判断是否出现死循环调用
      this.$console.log('==row.parentPlanId=',row.parentPlanId)
      if(row.id == row.parentPlanId){
        this.$message({
          type: 'warning',
          message: '父计划不能是自己，请修改后提交!'
        });
        done();
        return false;
      }
      else if(row.parentPlanId){
        this.isFound = false;
        this.foundByIteration(row.id,row.id,row.parentPlanId)
        if(this.isFound){
          this.$message({
            type: 'warning',
            message: '父计划出现了循环引用，请修改后提交!'
          });
          done();
          return false;
        }
        this.$console.log('isFound==',this.isFound)
      } 

      this.reqParams.singleBody = {
        ...this.planForm,
        id: null,
        milestoneName: this.planForm.$milestoneId,
        parentPlanName: this.planForm.$parentPlanId,
        prevPlanName: this.planForm.$prevPlanId,
        respsbltPersonName:this.$util.formatUserName(this.planForm.respsbltPersonName).userName,// 使用人名
        respsbltPersonUserName:this.$util.formatUserName(this.planForm.respsbltPersonName).userId// 使用用户名
      }
      this.commonData = reqCommonMsg(this.reqParams)
      updateBizPlanManage(this.commonData).then(() => {
        done();
        this.singleBody={}
        this.updatePlanDialog = false
        this.loadPlanList();
        this.$message({
          type: 'success',
          message: '修改成功!'
        });
      }, error => {
        done();
      });
    },
    /**
     * 删除一条记录
     */
    deletePlan(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.singleBody = row;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteBizPlanManage(this.commonData);
        })
        .then(() => {
          this.loadPlanList();
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {});
    },
    //加载数据
    async loadAllData(){
      await this.loadIteration();
      await this.loadMilestone();
      await this.loadPlanList()
    },
    /**
     * 获取业务字典参数
     */
    async getBizDict() {
      let dicData = await this.$params.getBizDict('["priorLevel"]');
      this.findObject(this.planOption.column, 'priorLevel').dicData = dicData.priorLevel;
      this.findObject(this.addPlanOption.column, 'priorLevel').dicData = dicData.priorLevel;
      this.findObject(this.updatePlanOption.column, 'priorLevel').dicData = dicData.priorLevel;
    },
    /**
     * 调用子组件方法查询历史
     */
    getHistoryRecord () {
      setTimeout(() => {
        this.$refs.historyRecord.getUpdateHistoryRecord(this.planForm.id);
      })
    },
  },
  created() {
    this.showColumn = this.$getStore({name: this.userInfo.userId+'bizPlanManageColumn'});
    //初始化数据
    setTimeout(() => {
      this.getBizDict();
    }, 1000);
    //加载数据
    this.loadAllData();
  },
  watch: {
    milestoneData: {
      handler(newValue, oldValue) {
        this.isDragChange = true;
      },
      deep: true
    },
    showColumn: {
      handler(newValue, oldValue) {
        this.$setStore({name: this.userInfo.userId+'bizPlanManageColumn', content: this.showColumn});
      },
      deep: true
    }
  }
};
</script>
<style lang="scss">
  .el-aside {
    color: #333;
  }
  .plan-container .el-main {
    margin-left: 0px !important;
    border-left: 0px solid #f3f3f3 !important;
    min-height: 700px;
  }
  //看板
  .board {
  margin-left: 20px;
  display: flex;
  justify-content: space-around;
  flex-direction: row;
  align-items: flex-start;
  
}
.kanban {
  &.todo {
    .board-column-header {
      background: #4A9FF9;
    }
  }
  &.working {
    .board-column-header {
      background: #f9944a;
    }
  }
  &.done {
    .board-column-header {
      background: #2ac06d;
    }
  }
}
.add-more{
  padding: 12px;
  text-align: center;
  float: left;
  width:300px; 
  margin:10px;
  margin-bottom:30px;
  background: #ffffff;
  border:1px solid  #e1e1e1;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}
.add-more:hover{
  background: #f6f6f6;
}
.kanban-select .avue-select input{
  //height: 30px;
}
.kanban-select .avue-form__group{
    height: 40px !important;
}

.avue-main .el-main .avue-crud__search .el-card__body{
  padding-top: 0px !important;
}
.avue-main .el-main .el-card__body {
  padding-top: 0px !important;
}

.avue-main .el-main .el-form-item--small .el-form-item__content, .avue-main .el-main .el-form-item--small .el-form-item__label {
  padding-top: 7px;
}
</style>    
